# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pycairo

pkgname="${MINGW_PACKAGE_PREFIX}-python3-cairo"
pkgver=1.10.0
pkgrel=3
pkgdesc="Python2 bindings for the cairo graphics library (mingw-w64)"
url="http://www.cairographics.org/pycairo"
arch=('any')
license=('LGPL' 'MPL')
depends=("${MINGW_PACKAGE_PREFIX}-python3" "${MINGW_PACKAGE_PREFIX}-cairo")
source=(http://cairographics.org/releases/${_realname}-${pkgver}.tar.bz2
    context.patch
    pycairo-1.10.0-waf-python3.4.tar.bz2)
md5sums=('e6fd3f2f1e6a72e0db0868c4985669c5'
         'd4ded5af833f9072954c8bc434f90986'
         '06a60ae51953a2d4e89eb46ac4d282f6')

build() {
  cd "${srcdir}/pycairo-${pkgver}"
  patch -p1 -i ${srcdir}/context.patch
  patch -p1 -i ${srcdir}/pycairo-1.10.0-waf-python3.4.patch
  sed -i 's:bin/env python:bin/env python3:' waf
  /usr/bin/python3 ./waf --version || true
  pushd .waf3-*
  #patch -p0 -i ${srcdir}/waflib.patch
  #rm -f waflib/*.pyc
  popd

  CFLAGS+=" -I${MINGW_PREFIX}/include/python3.4m"
  #CXXFLAGS+=" -I${MINGW_PREFIX}/include/python3.4m"
  export PYTHON=${MINGW_PREFIX}/bin/python3
  /usr/bin/python3 ./waf --help
  /usr/bin/python3 ./waf configure --prefix=${MINGW_PREFIX}
  /usr/bin/python3 ./waf build
}

package() {
  cd "${srcdir}/pycairo-${pkgver}"
  /usr/bin/python3 ./waf install --destdir="${pkgdir}"
  
  rm -rf ${pkgdir}${MINGW_PREFIX}/lib
  mv ${pkgdir}${MINGW_PREFIX}/bin ${pkgdir}${MINGW_PREFIX}/lib
}
